package atm.zhaz;

import java.awt.event.ActionEvent;

public class WithdrawWindow extends OneFieldForm {
	MyClient client;

	public WithdrawWindow(MyClient c) {
		super("Withdrawal", "amount");
		client = c;
	}

	public void showMessage(String s) {
		MessageWindow w = new MessageWindow(s);
		w.setVisible(true);
		System.out.println(s);
	}

	@Override
	public void actionPerformed(ActionEvent e) {
		long k = client.withdraw(Long.parseLong(getLogin1()));
		if (k == -1) {
			showMessage("Not enough money/ communication error");
		} else {
			showMessage("Success. you balance is: " + k);
		}
		setVisible(false);
	}


}
